# The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
def guess(num):
    r = 2
    if num == r:
        return 0
    elif num > r:
        return -1
    else:
        return 1

class Solution(object):
    def guessNumber(self, n):
        """
        :type n: int
        :rtype: int
        """
        l = 1
        h = n
        while l < h:
            g = (l + h) // 2
            r = guess(g)
            if r == 0:
                return g
            elif r == 1:
                l = g + 1
            else:
                h = g - 1

        return h

s = Solution()
print(s.guessNumber(2))